<template>
    <d2-container>
            <el-form ref="detailForm" :model="detailForm" label-width="100px">
                <el-form-item label="商品列表">
                    <el-table :data="detailForm.products" style="width: 100%">
                        <el-table-column prop="product.product.name" label="商品名称">
                            <template slot-scope="scope">
                                {{ scope.row.product.product.name}}[{{ scope.row.product.attributes[0]}}]
                            </template>
                        </el-table-column>
                        <el-table-column prop="product._id" label="商品ID"/>
                        <el-table-column prop="amount" label="数量"/>
                    </el-table>
                </el-form-item>
                <!-- <el-form-item label="优惠券列表">
                    <el-table :data="detailForm.coupon" style="width: 100%">
                        <el-table-column prop="title" label="优惠券名称"/>
                        <el-table-column prop="validType" label="门店名称"/>
                        <el-table-column prop="validType" label="类型"/>
                        <el-table-column prop="discountType" label="折扣类型"/>
                        <el-table-column prop="discount" label="折扣"/>
                    </el-table>
                </el-form-item> -->
                <el-form-item label="订单状态">
                    <el-select style="width: 40%" disabled v-model="detailForm.status" placeholder="请选择">
                        <el-option
                                v-for="item in statusAry"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value">
                        </el-option>
                    </el-select>
                </el-form-item>
                <!-- <el-form-item label="总价">
                    <el-input-number style="width: 40%" disabled v-model="detailForm.total" controls-position="right"></el-input-number>
                </el-form-item> -->
                <el-form-item label="积分总价">
                    <el-input-number style="width: 40%"  disabled v-model="detailForm.totalPoint" controls-position="right"></el-input-number>
                </el-form-item>
                <el-form-item label="寄货地址:">
                    {{detailForm.address.userName}} {{detailForm.address.telNumber}}  {{detailForm.address.provinceName}}{{detailForm.address.cityName}}{{detailForm.address.countyName}}{{detailForm.address.detailInfo}}
                </el-form-item>
                <el-form-item label="物流信息:">
                    {{detailForm.logisticsCompany}}&nbsp;&nbsp;&nbsp;&nbsp;{{detailForm.shipmentNumber}} 
                </el-form-item>
                <el-form-item label="用户备注">
                    <el-input
                            disabled
                            style="width: 40%"
                            type="textarea"
                            :autosize="{ minRows: 2, maxRows: 4}"
                            placeholder="用户备注"
                            v-model="detailForm.comment">
                    </el-input>
                </el-form-item>
                <el-form-item label="内部人员备注">
                    <el-input
                            style="width: 40%"
                            type="textarea"
                            :autosize="{ minRows: 2, maxRows: 4}"
                            placeholder="用户备注"
                            v-model="detailForm.memo">
                    </el-input>
                </el-form-item>
                <el-form-item style="overflow: hidden">
                    <div v-if="type" style="float: right">
                        <el-button @click="fnRejectReimburse" type="primary" >拒绝退款</el-button>
                        <el-button @click="fnApproveReimburse">同意退款</el-button>
                    </div>
                    <!-- <div style="float: left">
                        <el-button type="primary" @click="submitForm('detailForm')">确定</el-button>
                        <el-button @click="resetForm('detailForm')">重置</el-button>
                    </div> -->
                </el-form-item>
            </el-form>
    </d2-container>
</template>

<script>
import { getOneOrder, rejectReimburse, approveReimburse } from '@/api/admin'
  export default {
    name: 'changeOrder',
    data(){
      return {
        statusAry: [
            {label: '代付款', value: 0},
            {label: '已付款', value: 1},
            {label: '退款', value: 2},
            {label: '已退款', value: -1},
            {label: '退款中', value: 3},
            {label: '已发货', value: 4},
            {label: '撤销', value: 5}
        ],
        detailForm: {},
        type: '',
        reimId: ''
      }
    },
    created () {
      this.id = this.$route.query.id
      this.type = this.$route.query.type
      this.reimId = this.$route.query.reimId
      if(this.id) {
        this.getOneDetail()
      }
    },
    methods: {
        async getOneDetail() {
          const res = await getOneOrder({id: this.id})
          this.detailForm = res.data
        },
        fnRejectReimburse() {
            rejectReimburse({id: this.reimId}).then(res => {
                this.$alert('已拒绝退款申请', '提示', {
                    confirmButtonText: '确定',
                    callback: action => {
                        
                    }
                });
            })
        },
        fnApproveReimburse() {
            approveReimburse({id: this.reimId}).then(res => {
                this.$alert('退款申请已通过', '提示', {
                    confirmButtonText: '确定',
                    callback: action => {
                        
                    }
                });
            })
        }
    }
  }
</script>

<style scoped>

</style>
